package com.mm.user.controller;


import com.mm.common.annotation.Log;
import com.mm.common.domain.po.Result;
import com.mm.user.domain.po.Message;
import com.mm.user.service.MessageServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * @BelongsProject: 0.forum_system
 * @BelongsPackage: com.example.forum_system.controller
 * @Author : 游在海里的鱼
 * @CreateTime : 2023-11-13  20:15
 * @Version : 1.0
 * @Description : TODO
 */
@Slf4j
@RestController
@RequestMapping("/message")
@RequiredArgsConstructor
@Api(tags = "消息相关接口")
public class MessageController {

    private final MessageServiceImpl messageService;

    @Log(name = "发送消息")
    @ApiOperation("发送消息")
    @PostMapping("/sendMessage")
    public Result sendMessage(Message message){
        return messageService.sendMessage(message);
    }

    @Log(name = "获取所有消息")
    @ApiOperation("获取所有消息")
    @GetMapping("/getAllMessage")
    public Result getAllMessage(){
        return messageService.getAllMessage();
    }

    @Log(name = "已读消息")
    @ApiOperation("已读消息")
    @PostMapping("/readMessage")
    public Result readMessage(Long id){
        return messageService.readMessage(id);
    }
}
